package com.jingbian.cppccbackend.controller.admin;

import com.jingbian.cppccbackend.entity.HomePageBanner;
import com.jingbian.cppccbackend.entity.Result;
import com.jingbian.cppccbackend.service.admin.HomePageBannerService;
import com.jingbian.cppccbackend.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 主页轮播图表，用于存储轮播图信息 前端控制器
 * </p>
 *
 * @author yezi
 * @since 2025-03-02
 */
@RestController
@RequestMapping("/admins/homePageBanner")
public class adminHomePageBannerController {

    @Autowired
    private HomePageBannerService homePageBannerService;

    @GetMapping("/list")
    public Result<List<HomePageBanner>> getAllBanners() {
        List<HomePageBanner> banners = homePageBannerService.list();
        return ResultUtil.success(banners);
    }

    @PutMapping("/clearUrl/{bid}")
    public Result<String> clearUrl(@PathVariable Integer bid) {
        homePageBannerService.clearUrl(bid);
        return ResultUtil.success("图片已清除");
    }
}
